package main

import (
	"fmt"
	"reflect"
)

func main() {
	s := StudentScore{Chinese: 11.11, Math: 22.22, English: 33.33}
	f := s.CalculateTotalQuotaIsOneHundred(s)
	fmt.Println(f)
}

type StudentScore struct {
	Id      int64
	Chinese float64 `score:"true"`
	Math    float64 `score:"true"`
	English float64 `score:"true"`
}

func (m *StudentScore) CalculateTotalQuotaIsOneHundred(model StudentScore) float64 {
	typeOf := reflect.TypeOf(model)
	totalScore := float64(0)
	for i := 0; i < typeOf.NumField(); i++ {
		field := typeOf.Field(i)
		if field.Tag.Get("score") == "true" {
			totalScore += reflect.ValueOf(model).Field(i).Float()
		}
	}
	return totalScore
}
